package com.qf.service.impl;

import com.qf.dao.ProjectDao;
import com.qf.dao.StageDao;
import com.qf.pojo.Project;
import com.qf.pojo.Stage;
import com.qf.service.StageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/9/3 0:36
 * @Pacakge: com.qf.service.impl
 * @ClassName: StageServiceImpl
 * @Author: fan
 */
@Service("stageService")
public class StageServiceImpl implements StageService {
    @Autowired
    private StageDao stageDao;
    @Autowired
    private ProjectDao projectDao;
    @Override
    public List<Stage> findAllStage() {
        List<Stage> list = stageDao.findAllStage();
        for (Stage stage:list){
            List<Project> projects = projectDao.findProjectByPid(stage.getPid());
            if (projects != null && projects.size()!= 0){
                Project project = projects.get(0);
                stage.setProject(project);
            }
        }
        return list;
    }
}
